import React from 'react';
import { routerRedux, Switch } from 'dva/router';

import Authorized from '@/components/Authorized';

import { dynamicWrapper } from '@/utils/router';
import * as H from 'history';

const { ConnectedRouter } = routerRedux;

const { DefaultAuthorizedRoute, PublicAuthorizedRoute } = Authorized;

interface ZhiQueProps {
  history: H.History;
}

const ZhiQue: React.FC<ZhiQueProps> = ({ history }) => {

  return (
    <ConnectedRouter history={history}>
      <Switch>
        <DefaultAuthorizedRoute
          path="/console"
          component={dynamicWrapper({
            component: () => import('./layouts/Layout')
          })}
        />
        <PublicAuthorizedRoute
          path="/"
          component={dynamicWrapper({
            component: () => import('./layouts/Layout')
          })}
        />
      </Switch>
    </ConnectedRouter>
  );
};

export default ZhiQue;
